﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace HeathCareSystem.Tier
{
    /// <summary>
    /// Summary description for ACMaBenhNhan
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class ACMaBenhNhan : System.Web.Services.WebService
    {
        public ACMaBenhNhan()
        {
        }

        [WebMethod]
        public string[] GetListMaBenhNhan(string prefixText, int count)
        {
            List<BenhNhanDTO> lst = new BenhNhanBUS().TimBenhNhanTheoMaBenhNhan(prefixText);
            int c = lst.Count;
            List<string> items = new List<string>(c);
            for (int i = 0; i < c; i++)
            {
                items.Add(lst[i].maBenhNhan);
            }

            return items.ToArray();
        }

        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            if (count == 0)
            {
                count = 10;
            }

            if (prefixText.Equals("xyz"))
            {
                return new string[0];
            }

            Random random = new Random();
            List<string> items = new List<string>(count);
            for (int i = 0; i < count; i++)
            {
                char c1 = (char)random.Next(65, 90);
                char c2 = (char)random.Next(97, 122);
                char c3 = (char)random.Next(97, 122);

                items.Add(prefixText + c1 + c2 + c3);
            }

            return items.ToArray();
        }

        private void InitializeComponent()
        {

        }
        
    }
}
